package com.cloud.api.myenum;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

public enum SexEnum implements IEnum<Integer> {
    MALE(1, "男"),
    FEMALE(2, "女"),
    NONE(3, "未知");

    @EnumValue
    private Integer value;

    @JsonValue
    @Getter
    private String desc;

    SexEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @Override
    public Integer getValue() {
        return this.value;
    }

    public static SexEnum getByDesc(String desc) {
        for (SexEnum sex : SexEnum.values()) {
            if (sex.getDesc().equals(desc)) {
                return sex;
            }
        }
        return null;
    }
}
